package com.chak.voyage.utils;

import org.apache.commons.lang.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by delzh on 2016/9/4.
 */
public class HtmlFormatterUtil {

    public static String removeTag(String str){
        if (StringUtils.isNotBlank(str)) {
            String origin = str;
            int begin = str.indexOf("<");
            int end = str.indexOf(">");
            while (begin != -1 && end != -1) {
                String remove = str.substring(begin, end + 1);
                str = str.replace(remove, "");
                begin = str.indexOf("<");
                end = str.indexOf(">");
            }
            if (str.equals(origin)) {
                return null;
            } else {
                return str;
            }
        }
        else {
            return str;
        }
    }

    public static void main(String [] args){
        String str = HtmlFormatterUtil.removeTag("<ss>ss</ss><2></2><222>");
        System.out.println(str);
    }
}
